async-dup
Duplicate an async I/O handle.
This crate provides two tools, Arc
and Mutex
:
Arc
implementsAsyncRead
,AsyncWrite
, andAsyncSeek
if a reference to the inner type does.- A reference to
Mutex
implementsAsyncRead
,AsyncWrite
, andAsyncSeek
if the inner type does.
Wrap an async I/O handle in Arc
or Mutex
to clone it or share among tasks.
Examples
Clone an async I/O handle:
use Arc;
use io;
use Async;
use TcpStream;
// A client that echoes messages back to the server.
let stream = connect.await?;
// Create two handles to the stream.
let reader = new;
let mut writer = reader.clone;
// Echo data received from the reader back into the writer.
copy.await?;
Share an async I/O handle:
use Mutex;
use io;
use *;
// Reads data from a stream and echoes it back.
async
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.